<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>JS - 1.3</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width">
        <script>
            function compterNbreMots() {
                var valeurTexte = document.formulaire.champTexte.value;
                var elementResultat = document.formulaire.champResultat;

                valeurTexte = valeurTexte.split(" ");

                var resultatNbreCaracteres = valeurTexte.length;

                elementResultat.value = resultatNbreCaracteres;

            }
        </script>
    </head>

    <body>
        <form name="formulaire">
            <input type="text" name="champTexte" value="">
            <input type="button" value="Compter le nombre de mots !" onclick="compterNbreMots();">
            <input type="text" name="champResultat" value="">
        </form>
    </body>
</html>
